package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
)

func main() {
	for k, url := range os.Args[1:] {
		if k == 1 {
			continue
		}
		resp, error := http.Get(url)
		if error != nil {
			fmt.Fprint(os.Stderr, "%v\n", error)
			os.Exit(1)
		}
		s, error := ioutil.ReadAll(resp.Body)
		resp.Body.Close()
		if error != nil {
			fmt.Fprint(os.Stderr, "%v\n", error)
			os.Exit(1)
		}
		err := ioutil.WriteFile("test1", s, os.ModeAppend)

		if err != nil {
			fmt.Fprintf(os.Stderr, "%v\n", error)
		} else {
			log.Println("写入成功")
		}
	}
}
